package com.runda.partypolicy.app.page.adapter;

import android.content.Context;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.runda.partypolicy.R;

import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;


public class RedPagerAdapter extends FragmentPagerAdapter {
    private List<Fragment> list;
    private String[]   titles;
    Context context;

    public RedPagerAdapter(FragmentManager fm, List<Fragment> list, String[]   titles, Context context) {
        super(fm);
        this.list = list;
        this.context = context;
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    public View getTabView(int position) {
        View tabView = LayoutInflater.from(context).inflate(R.layout.item_tab_layout, null);
        TextView tabTitle = (TextView) tabView.findViewById(R.id.tv_tab_title);
        tabTitle.setText(titles[position]);
        return tabView;
    }
}
